﻿@model cloudscribe.Core.Web.ViewModels.CoreData.GeoCountryViewModel
@using cloudscribe.Core.Web
@using Microsoft.Extensions.Options
@using Microsoft.Extensions.Localization
@inject IStringLocalizer<CloudscribeCore> sr
<div class="row">
    <div class="col-md-10 col-md-push-2">
        <h2>@ViewData["Title"]</h2>
        <form role="form" class="form-horizontal" asp-controller="CoreData" asp-action="CountryEdit" data-submit-once="true">
            <div asp-validation-summary="All" class="text-danger"></div>
            <input asp-for="Id" type="hidden" />
            <div class="form-group">
                <label asp-for="Name" class="col-md-2 control-label">@sr["Name"]</label>
                <div class="col-md-10">
                    <input asp-for="Name" class="form-control" />
                    <span asp-validation-for="Name" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group">
                <label asp-for="ISOCode2" class="col-md-2 control-label">@sr["ISOCode2"]</label>
                <div class="col-md-10">
                    <input asp-for="ISOCode2" class="form-control" />
                    <span asp-validation-for="ISOCode2" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group">
                <label asp-for="ISOCode3" class="col-md-2 control-label">@sr["ISOCode3"]</label>
                <div class="col-md-10">
                    <input asp-for="ISOCode3" class="form-control" />
                    <span asp-validation-for="ISOCode3" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-offset-2 col-md-10">
                    <a class="btn btn-default" asp-action="CountryListPage" asp-route-pagenumber="@Model.ReturnPageNumber">@sr["Back To Country List"]</a>
                    <button name="submit" type="submit" class="btn btn-default" data-enabled-text='@sr["Save"]' data-disabled-text='@sr["Working..."]'>@sr["Save"]</button>
                    @if (Model.Id != Guid.Empty)
                    {
                        <button type="button" class="btn btn-danger" data-toggle="modal" data-target="#confirmDeleteModal">
                            @sr["Delete"]
                        </button>
                    }
                </div>
            </div>
        </form>
        @if (Model.Id != Guid.Empty)
        {
            <form id="deleteform" asp-controller="CoreData" asp-action="CountryDelete">
                <input type="hidden" id="countryId" name="countryId" value="@Model.Id" />
                <input type="hidden" asp-for="ReturnPageNumber" />
                <div class="modal fade" id="confirmDeleteModal" tabindex="-1" role="dialog" aria-labelledby="confirmDeleteHeading">
                    <div class="modal-dialog modal-sm" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-label='@sr["Close"]'><span aria-hidden="true">&times;</span></button>
                                <h4 class="modal-title" id="confirmDeleteHeading">@sr["Confirm Delete"]</h4>
                            </div>
                            <div class="modal-body">
                                @string.Format(sr["Are you sure you want to delete the country {0} and all of its states? You cannot undo this action."], Model.Name)
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">@sr["Cancel"]</button>
                                <input type="submit" value='@sr["Delete"]' class="btn btn-danger btn-ok" />
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        }

    </div>
    <div class="col-md-2 col-md-pull-10 hidden-xs hidden-sm">
        @await Component.InvokeAsync("Navigation", new { viewName = "SideNavAlt1", filterName = NamedNavigationFilters.ParentTree, startingNodeKey = "SiteAdmin" })
    </div>
</div>
@section scripts {
    @{ await Html.RenderPartialAsync("_SideMenuScriptsPartial"); }
    @{ await Html.RenderPartialAsync("_UnobtrusiveValidationScriptsPartial"); }
    <script src="~/cr/js/jquery.validate.hooks.min.js"></script>
    <script src="~/cr/js/jqueryvaildation.submitonce-unobtrusive.min.js"></script>
}


